package com.hualan.sfzy.controller.mind;

import com.hualan.sfzy.entity.mind.TestProblemSelect;
import com.hualan.sfzy.service.mind.TestProblemSelectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("testProblemSelect")
public class TestProblemSelectController {
    @Autowired
    private TestProblemSelectService testProblemSelectService;

    @PostMapping
    public int insert(@RequestBody TestProblemSelect testProblemSelect) {
        return testProblemSelectService.add(testProblemSelect);
    }

    @PutMapping
    public int update(@RequestBody TestProblemSelect testProblemSelect) {
        return testProblemSelectService.edit(testProblemSelect);
    }

    @DeleteMapping("/{id}")
    public int delete(@RequestParam Integer id) {
        return testProblemSelectService.remove(id);
    }

    @DeleteMapping()
    public int deleteBatch(@RequestParam Integer[] ids) {
        return testProblemSelectService.removeBatch(ids);
    }

    @GetMapping
    public List<TestProblemSelect> select(@RequestBody TestProblemSelect testProblemSelect) {
        return testProblemSelectService.find();
    }

    @GetMapping("/{id}")
    public TestProblemSelect selectById(@RequestParam Integer id) {
        return testProblemSelectService.findById(id);
    }

    @GetMapping("/page")
    public Map<String, Object> findByPage(@RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "10") Integer pageSize,
                                          TestProblemSelect testProblemSelect) {
        return testProblemSelectService.findByPage(pageNum, pageSize, testProblemSelect);
    }
}